// These are meant to be typed into the REPL. You can also run
// scala -Xnojline < 06_transfer.sc to run them all at once.
/**
  * 14.6 利用隐式参数进行隐式转换
  * 考虑下面一个函数，编译时通不过的，类型参数不能确定是一个带有<操作符的类型。
  * def smaller[T](a: T, b: T)
  * = if (a < b) a else b
  *
  * 我们可以通过隐式参数将定义改写如下:
  **/
def smaller[T](a: T, b: T)(implicit order: T => Ordered[T])
  = if (order(a) < b) a else b

smaller(40, 2)

smaller("Hello", "World")

def smaller1[T](a: T, b: T)(implicit order: T => Ordered[T])
  = if (a < b) a else b // Can omit call to order

smaller1(40, 2)

smaller1("Hello", "World")

